<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流动文字</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        h4 {
            font-size: 30px;
            text-align: center;
            margin-top: 20%;
            background-image: -webkit-linear-gradient(left, #e9a5a5, #b8c1c0 10%, #65c0e0 20%, #aea2db 30%, #81c1d9 40%, #e9a5a5 50%, #b8c1c0 60%, #65c0e0 70%, #aea2db 80%, #81c1d9 90%, #e9a5a5);
            color: transparent;
        
            /* 将背景裁剪为文字 */
            -webkit-background-clip: text;
        
            /* 背景放大一倍，动画才有移动的空间 */
            background-size: 50% 100%;
        
            /* 动画 规定四秒执行完 无限循环 匀速播放 */
            animation: a 5s infinite linear;
        }
        
        @keyframes a {
            0% {
                background-position: 0 0;
            }
        
            100% {
                background-position: -100% 0;
            }
        }
    </style>
</head>

<body>
    <h4>CSS制作简单的流动文字</h4>
</body>

</html>
































<!-- https://space.bilibili.com/108279272 -->